<!--  角色管理页-->
<template>
  <ex_super_table_page
    v-bind="option"
    class="page-container"
    ref="SuperTablePage"
  >
  </ex_super_table_page>
</template>

<script>
import superTablePageFunction from "@/mixin/super-table-page-function";
import emitOnFunction from "@/mixin/emit-on-function";

let emitKey = "srm>supplier_product_transport";
export default {
  title: "label_srm_transport_supplier_line",
  mixins: [superTablePageFunction, emitOnFunction(emitKey)],
  components: {},

  data() {
    return {
      option: {
        search: {
          model: [
            {
              label: "label_srm_insurance_supplier",
              key: "supplyId",
              type: "select",
              url: "/srm-api/supplier/SupplierRpc/selectPage.json",
              urlParams: { pageIndex: 1, pageSize: 9999 },
              option: { label: "supplierName", value: "id" }
            },
            {
              label: "label_status",
              key: "status",
              type: "select",
              enum:"IsAvailableStatusEnum"
            }
          ]
        },
        action: [
          {
            label: "label_srm_transport_add",
            attrs: { icon: "el-icon-plus" },
            auth: "srm_product_transport_edit",
            click: () => {
              this.$router.push({
                path: "/page/srm/product/srm_transport_edit",
                query: { emitKey }
              });
            }
          }
        ],

        table: {
          url:
            "/fms-api/product/PmsSupplyProductRpc/selectProduct.json?productType=TRANSPORT",
          model: [
            { key: "supplyName", label: "label_srm_insurance_supplier_name" },
            {
              key: "productName",
              label: "label_srm_transport_logistics_route_name"
            },
            {
              key: "transportLineForm",
              label: "label_srm_transport_line_info",
              align: "left",
              attrs: {
                formatter: (r, c, v, i) => {
                  return (
                    r.transportLineForm.originPlaceName +
                    " -> " +
                    r.transportLineForm.destPlaceName
                  );
                }
              }
            },
            {
              key: "apiServiceName",
              label: "label_srm_insurance_platform",
              attrs: {
                formatter: (r, c, v, i) => {
                  return r.apiServiceTypeName + "-" + r.apiServiceName;
                }
              }
            },

            {
              key: "status",
              label: "label_status",
              attrs: {
                formatter: (r, c, v, i) => {
                  return v == "ENABLE" ? "启用" : "禁用";
                }
              }
            },
            // {key: 'remark', label: '备注'},
            // {key: 'creator', label: '创建人',},
            {
              key: "gmtModify",
              label: "label_modify_user",
              attrs: {
                formatter: (r, c, v, i) => {
                  return r.modifier + " " + this.$dateFormat(v);
                }
              }
            },
            {
              type: "operate",
              width: 220,
              operate: [
                {
                  label: "label_edit",
                  auth: "srm_product_transport_edit",

                  click: row => {
                    this.$router.push({
                      path: "/page/srm/product/srm_transport_edit",
                      query: { id: row.id, emitKey, edit: true }
                    });

                    // this.$router.push({
                    //   name: '/page/srm/product/srm_transport_edit', params: {
                    //     title: '修改供应商保险服务',  query:{ id: row.id } , callback: () => {
                    //       this.reload()
                    //     }
                    //   }
                    // });
                  }
                },
                {
                  label: "IsAvailableStatusEnum__ENABLE",
                  auth: "srm_product_transport_disable",

                  type: "confirm-button",
                  url: "/fms-api/product/PmsSupplyProductRpc/updateStatus.json",
                  message: "label_sure_to_enable_this",
                  if: row => !row.status || row.status == "DISABLED",
                  params: row => {
                    return { id: row.id, status: "ENABLE" };
                  },
                  done: ["reload", "tip"]
                },
                {
                  label: "IsAvailableStatusEnum__DISABLED",
                  auth: "srm_product_transport_disable",

                  type: "confirm-button",
                  url: "/fms-api/product/PmsSupplyProductRpc/updateStatus.json",
                  message: "label_sure_to_disable_this",
                  if: row => row.status == "ENABLE",
                  params: row => {
                    return { id: row.id, status: "DISABLED" };
                  },
                  done: ["reload", "tip"]
                }
                //,
                // {
                //   label: "删除",
                //   type: 'confirm-button',
                //   url: '/fms-api/product/PmsSupplyProductRpc/removeProduct.json',
                //   message: '确定要删除该记录吗？',
                //   params: (row) => {
                //     return {id: row.id}
                //   },
                //   done: ['reload', 'tip']
                // }
              ]
            }
          ]
        }
      }
    };
  },

  created() {},

  destroyed() {},

  methods: {}
};
</script>
<style></style>
